package com.app.service.impl;


import com.app.mapper.IncubatorsArticleMapper;
import com.app.mapper.IncubatorsMapper;
import com.app.model.IncubatorsArticleModel;
import com.app.model.IncubatorsModel;
import com.app.service.IncubatorsArticleService;
import com.app.service.IncubatorsService;
import com.app.util.StringTool;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


/**
 * @Description:专家
 * @Author: N
 * @Date: 2022年11月24日 10点29分
 */
@Service
public class IncubatorsArticleServiceImpl implements IncubatorsArticleService {

    @Autowired
    IncubatorsArticleMapper incubatorsArticleMapper;



    @Override
    public IncubatorsArticleModel getModelByFather(Integer fatherId, Integer type) {
        QueryWrapper<IncubatorsArticleModel> queryWrapper = new QueryWrapper<>();
        if(fatherId!=null&&fatherId>0)
        {
            queryWrapper.eq("father_id",fatherId);
        }
        if(type!=null&&type>0)
        {
            queryWrapper.eq("type",type);
        }
        List<IncubatorsArticleModel> list = incubatorsArticleMapper.selectList(queryWrapper);
        if(list!=null&&list.size()>0)
        {
            return list.get(0);
        }else {
            return null;
        }
    }

    @Override
    public int insert(IncubatorsArticleModel model) {
        return incubatorsArticleMapper.insert(model);
    }

    @Override
    public void update(IncubatorsArticleModel model) {
        incubatorsArticleMapper.updateById(model);
    }

    @Override
    public void delete(Integer id) {
        incubatorsArticleMapper.deleteById(id);
    }
}
